package EVO;


import EVO.domain.Student;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public class MyApp {
    public static void main(String[] args) {
        String config = "myBatis.xml";
        InputStream in = null;
        try {
            in = Resources.getResourceAsStream(config);

            SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();

            SqlSessionFactory factory = builder.build(in);

            SqlSession sqlSession = factory.openSession();

            String sqlId = "EVO.dao.StudentDao"+"."+"selectStudents";

            List<Student> stuList = sqlSession.selectList(sqlId);

            for(Student stu : stuList){
                System.out.println(stu);
            }

            sqlSession.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
